package com.sheepych.water_clock;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author yangchanghai
 */
@Slf4j
@Component
public class Task {
    @Autowired
    private SendWaterMsgService sendWaterMsgService;
    @Autowired
    private SendHealthMsgService sendHealthMsgService;

    // 每周1-6（周一到周六）9:00-12:00，14:00-18:00 每30分钟执行
    @Scheduled(cron = "0 0/30 9-12,14-18 ? * MON-SAT")
    public void run() {
//        log.info("开始执行任务....");
        sendWaterMsgService.sendMsg();
    }

    // 每周1-6（周一到周六）9:00-12:00，14:00-18:00 每60分钟执行
    @Scheduled(cron = "0 45 10-11,14-18 ? * MON-SAT")
    public void run2() {
//        log.info("开始执行任务....");
        sendHealthMsgService.sendMsg();
    }
}